package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryDTO;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @author 老杨
 * @version 1.0
 */
@Mapper
public interface CategoryMapper {
    /**
     * 根据 type 查询类别
     */

    Page<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

    @AutoFill(OperationType.INSERT)
@Insert("insert into category values (null,#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Category category);

@Delete("delete from category where id = #{id}")
    void delete(Integer id);

    @AutoFill(OperationType.UPDATE)
    void update(Category category);


    /**
     * 根据 类型 查询 类别
     * @param type
     * @return
     */
    List<Category> list(Integer type);
}
